﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;

namespace LaneLpnr.Led
{
    class TFIProgram
    { //创建LED设备对象  返回设备对象句柄
        [DllImport("TFI.dll", EntryPoint = "TFI_Create", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern IntPtr TFI_Create();

        //释放对象句柄  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_Destroy", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_Destroy(IntPtr handle);

        //打开指定串口  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_OpenCom", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_OpenCom(IntPtr handle, int iComID);

        //打开指定ip地址  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_OpenNet", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_OpenNet(IntPtr handle, string ip);

        //关闭设备连接  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_Close", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_Close(IntPtr handle);

        //清屏  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_ClearAll", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_ClearAll(IntPtr handle);

        //发送语音成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_SendVoice", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_SendVoice(IntPtr handle, string str);

        //发送单行内容 成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_SendLine", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_SendLine(IntPtr handle, int nLineNo, uint nColor, int nRollMode, int nRollSpeed, string szText);

        //设置显示模式  成功返回true  现在只有行模式
        [DllImport("TFI.dll", EntryPoint = "TFI_SetMode", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_SetMode(IntPtr handle, byte mode, string pRowType);

        //发送多行文字 在页模式下显示  每行都是左对齐
        [DllImport("TFI.dll", EntryPoint = "TFI_SendMultiLine", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_SendMultiLine(IntPtr handle, uint nColor, string szText);

        //获取显示屏信息  成功返回true
        [DllImport("TFI.dll", EntryPoint = "TFI_GetDeviceInfo", SetLastError = true, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Ansi)]
        public static extern bool TFI_GetDeviceInfo(IntPtr handle, string pInfo);

    }
}
